"use strict";

/**
 * @auther wtfssd
 * Created by wtfssd on 2017/11/7
 */
import * as React from 'react'
const NavigationBar = require('react-native-navbar').default;
const {Actions} = require("react-native-router-flux");
import {commonProps, commonStyles} from "../../assets/styles/common";
import NavBackButton from "../../component/BackButton";
import MyText from "../../component/MyText";
import NavRightButton from "../../component/RightButton";
import Line from "../../component/Line";


const {View, ScrollView, KeyboardAvoidingView} = require('react-native');
const {connect} = require('react-redux');
const {List, InputItem, Switch, DatePicker, TextareaItem} = require('antd-mobile');
const {createForm} = require('rc-form');
const nowTimeStamp = Date.now();
const now = new Date(nowTimeStamp);
const utcOffset = new Date(now.getTime() - (now.getTimezoneOffset() * 60000));

class RemindPage extends React.Component<any, any> {

    constructor(props: any, context: any) {
        super(props, context);
        this.state = {
            start_time: now,
            end_time: now,
            idt: utcOffset.toISOString().slice(0, 10),
        }
    }


    render() {
        const {getFieldProps} = this.props.form;
        return (
            <View style={commonStyles.container}>
                <NavigationBar {...commonProps.navBar}
                               leftButton={<NavBackButton><MyText color={'#D8BB26'}>取消</MyText></NavBackButton>}
                               rightButton={<NavRightButton><MyText color={'#D8BB26'}>添加</MyText></NavRightButton>}
                               title={{title: '新建事件', tintColor: '#fff'}}
                />

                <KeyboardAvoidingView behavior='padding' contentContainerStyle={commonStyles.flex1}>
                    <ScrollView keyboardDismissMode={'on-drag'}>
                        <List style={{backgroundColor: 'transparent'}}>
                            <Line height={30} color={'#F4F4F4'}/>
                            <InputItem {...getFieldProps('name')} clear/>
                            <InputItem {...getFieldProps('address')} clear/>
                            <List.Item
                                extra={<Switch
                                    {...getFieldProps('whole_day', {
                                        initialValue: true,
                                        valuePropName: 'checked',
                                    })}
                                />}
                            >全天</List.Item>
                            <DatePicker
                                {...getFieldProps('start_time', {
                                    initialValue: this.state.start_time,
                                })}
                            >
                                <List.Item>开始</List.Item>
                            </DatePicker>
                            <DatePicker
                                {...getFieldProps('end_time', {
                                    initialValue: this.state.end_time,
                                })}
                            >
                                <List.Item>结束</List.Item>
                            </DatePicker>
                            <List.Item arrow="horizontal" extra={<MyText>永不</MyText>} onClick={Actions.repeat}>重复</List.Item>
                            <List.Item arrow="horizontal" extra={<MyText>无</MyText>}>交通时间</List.Item>
                            <Line height={30} color={'#F4F4F4'}/>
                            <List.Item arrow="horizontal" extra={<MyText>工作</MyText>}>日历</List.Item>
                            <List.Item arrow="horizontal" extra={<MyText>无</MyText>}>受邀人</List.Item>
                            <Line height={30} color={'#F4F4F4'}/>
                            <List.Item arrow="horizontal" extra={<MyText>无</MyText>}>提醒</List.Item>
                            <List.Item arrow="horizontal" extra={<MyText>正忙</MyText>}>显示为</List.Item>
                            <Line height={30} color={'#F4F4F4'}/>
                            <InputItem {...getFieldProps('url')} placeholder='URL' clear/>
                            <TextareaItem
                                {...getFieldProps('detail')}
                                rows={5}
                            />
                        </List>
                    </ScrollView>
                </KeyboardAvoidingView>


            </View>
        );
    }
}

const Wrapper = createForm()(RemindPage);
export default Wrapper;